package academic.service;

import academic.dao.WcqAcademicDao;
import academic.domain.WcqAcademic;
import common.dao.StudentDao;
import utils.DAOFactory;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class mentortest {
    private static WcqAcademicDao wcqAcademicDao = DAOFactory.getInstance().getWcqAcademicDao();
    private static StudentDao studentDao = DAOFactory.getInstance().getStudentDao();
    public static void main(String[] args) {
        System.out.println("xxx");
        System.out.println("请导师对活动1进行审核(1为通过,-1为不通过)：");
        Scanner input=new Scanner(System.in);
        int judge1= Integer.parseInt(input.next());
        System.out.println("请学科负责人对活动1进行审核(1为通过,-1为不通过)：");
        int judge2= Integer.parseInt(input.next());
        auditbymentor(1L,judge1);
        auditbyhead(1L,judge2);
    }
    public static void auditbymentor(Long activity_id,int judge)
    {
        WcqAcademic wcqAcademic=wcqAcademicDao.selectById(activity_id);
        Date date=new Date();

        if(judge==1)
        {
            if(wcqAcademic.getActivity_status2()==0) {
                wcqAcademic.setActivity_status1(1);
                SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                wcqAcademic.setActivity_status1_time(ft.format(date));
            }else if(wcqAcademic.getActivity_status2()==-1)
            {
                wcqAcademic.setActivity_status1(1);
                wcqAcademic.setActivity_status(-1);
                SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                wcqAcademic.setActivity_status1_time(ft.format(date));
            }else
            {
                wcqAcademic.setActivity_status1(1);
                wcqAcademic.setActivity_status(1);
                SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                wcqAcademic.setActivity_status1_time(ft.format(date));
            }
        }else
        {
            if(wcqAcademic.getActivity_status2()==0) {
                wcqAcademic.setActivity_status1(-1);
                SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                wcqAcademic.setActivity_status1_time(ft.format(date));
            }else
            {
                wcqAcademic.setActivity_status1(-1);
                wcqAcademic.setActivity_status(-1);
                SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                wcqAcademic.setActivity_status1_time(ft.format(date));
            }
        }
        wcqAcademicDao.updateById(wcqAcademic);
        System.out.println("导师对"+wcqAcademic.getActivity_name()+"活动申请审批结束");
    }
    public static void auditbyhead(Long activity_id,int judge)
    {
        WcqAcademic wcqAcademic=wcqAcademicDao.selectById(activity_id);
        Date date=new Date();
        if(judge==1)
        {
            if(wcqAcademic.getActivity_status1()==0) {
                wcqAcademic.setActivity_status2(1);
                SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                wcqAcademic.setActivity_status2_time(ft.format(date));
            }else if(wcqAcademic.getActivity_status1()==-1)
            {
                wcqAcademic.setActivity_status2(1);
                wcqAcademic.setActivity_status(-1);
                SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                wcqAcademic.setActivity_status2_time(ft.format(date));
            }else
            {
                wcqAcademic.setActivity_status2(1);
                wcqAcademic.setActivity_status(1);
                SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                wcqAcademic.setActivity_status2_time(ft.format(date));
            }
        }else
        {
            if(wcqAcademic.getActivity_status1()==0) {
                wcqAcademic.setActivity_status2(-1);
                SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                wcqAcademic.setActivity_status2_time(ft.format(date));
            }else
            {
                wcqAcademic.setActivity_status2(-1);
                wcqAcademic.setActivity_status(-1);
                SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                wcqAcademic.setActivity_status2_time(ft.format(date));
            }
        }

        wcqAcademicDao.updateById(wcqAcademic);
        System.out.println("学科负责人对"+wcqAcademic.getActivity_name()+"活动申请通过");
    }
}
